﻿// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "shadertoy/Simple Circle" {
	Properties{
		_Parameters("Circle Parameters", Vector) = (0.5, 0.5, 10, 1) // Center: (x, y), Radius: z  
		_CircleColor("Circle Color", Color) = (1, 1, 1, 1)
		_BackgroundColor("Background Color", Color) = (1, 1, 1, 1)
	}

	CGINCLUDE
		#include "UnityCG.cginc"     
		#include "ShaderToyLeran.cginc"

		float4 _BackgroundColor;
		float4 _Parameters;
		float4 _CircleColor;

		vec4 circle(vec2 pos, vec2 center, float radius, float3 color, float antialias) 
		{

			float d = length(pos - center) - radius;
			float t = smoothstep(0, antialias, d);
			//抗锯齿
			return vec4(color, 1.0 - t);
		}

		vec4 main(vec2 fragCoord) 
		{
			vec2 pos = fragCoord; // pos.x ~ (0, iResolution.x), pos.y ~ (0, iResolution.y)  

			vec4 layer1 = vec4(_BackgroundColor.rgb, 1.0);
			vec4 layer2 = circle(pos, _Parameters.xy * iResolution.xy, _Parameters.z, _CircleColor.rgb, _Parameters.w);

			return mix(layer1, layer2, layer2.a);
		}

	ENDCG

	SubShader
	{
			Pass
			{
				CGPROGRAM

				#pragma vertex VertexFunc      
				#pragma fragment FragFunc      

				ENDCG
			}
	}
	
	FallBack Off
}